<!DOCTYPE html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml" xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <style>
    .active {
      color: red;
    }
    .line {
      color: aqua;
    }
  </style>
</head>
<body>
<!--view层-->
<div id="app">
  <h1 class="active">{{message}}</h1>
  <h1 :class="active">{{message}}</h1>
  <h2 v-bind:class="active">{{message}}</h2>
  <h1>{类名;boolean} 写法,对象绑定写法,以下写法会和普通的class进行合并哦</h1>
  <h2 class="title" v-bind:class="{active:isActive,line:isLine}">{{message}}</h2>
  <h1>简便写法</h1>
  <h2 class="title" :class="getClass()">{{message}}</h2>
  <button v-on:click="test">变色</button>
</div>
<!--viewModel层-->
<script src="../../js/vue.js"></script>
<!--model层-->
<script>
  const app = new Vue({
    el: '#app',
    data: {
      message: '对象绑定:需求:listview中点击那个,那个显示颜色',
      active: 'active',
      isActive: false,
      isLine: true
    }, methods: {
      test: function (msg) {
        //声明方法
        this.isActive = !this.isActive,
        this.isLine=!this.isLine
      },
      getClass:function () {
        return {active:this.isActive,line:this.isLine}
      }
    }, created: function () {
      //生命周期
    }, mounted: function () {
      //生命周期
    }
  })
</script>
</body>
</html>